import React,{Component} from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import finalCreateStore from './store/index'
import reducer from './reducers/index'  
import { syncHistoryWithStore } from 'react-router-redux' ;
import { HashRouter as Router, Switch, Route, NavLink } from 'react-router-dom' ;
import routes from './router-config';
import { Home, Carts, Detail,NewsDetail, News, NewsList,ProListContext as ProList,LoginContext as Login ,NoMatch,Footer,Header} from './modules';
// 利用react-router-redux提供的syncHistoryWithStore我们可以结合store同步导航事件
import DevTools from './store/DevTools' ;


// 给增强后的store传入reducer
const store = finalCreateStore(reducer)

// // 创建一个增强版的history来结合store同步导航事件
 //const history = syncHistoryWithStore(hashHistory, store)

ReactDOM.render(
 <Provider store={store}>
  <Router >
    <div>
		<Header />
		<div>
			<Switch>
				<Route path="/" component={Home} exact={true}/>
				<Route path="/news" component={News} />
				<Route path="/login" component={Login} />
				<Route path="/logout" component={Login} />
				<Route path="/list" component={NewsList} />
				<Route path="/newslist/detail/:id" component={NewsDetail} />
				<Route path="/product/list/:cateId" component={ProList}/>
				<Route path="/detail/:id" component={Detail}/>
				<Route path="/cart" component={Carts}/>
				{/* <Route path="/cart" component={() =>
					(fakeAuth.isAuthenticated
						? (<Cart />)
						: (<Redirect to={{pathname: '/login',state: { from: '/cart'}
					}}/>))} /> */}
				<Route  component={NoMatch}/>
			</Switch> 
        </div>
		<Footer/>
    </div>
  </Router>
</Provider> 
,document.getElementById('app')); 
